package com.dzxcqmxm.servlet.photo;

import com.dzxcqmxm.Dao.PhotoDao;
import com.dzxcqmxm.Dao.UserDao;
import com.dzxcqmxm.Dao.impl.PhotoDaoImpl;
import com.dzxcqmxm.Dao.impl.UserDaoImpl;
import com.dzxcqmxm.JB.Photo;
import com.dzxcqmxm.JB.User;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;

/**
 * 首页和审核都要展示所有的照片
 */
@WebServlet("/findAllphotoServlet")
public class findAllphotoServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        PhotoDao photoDao = new  PhotoDaoImpl();
        Photo photo = new Photo();
        ArrayList<Photo> photoArrayList = new ArrayList<Photo>();
        try {
            photoArrayList = photoDao.findAllphoto();
        } catch (Exception e) {
            e.printStackTrace();
        }
        //就是把我们获取到的列表给设置成一次session会话，让它可以在jsp的会话中获取到。
        request.getSession().setAttribute("photoArrayList",photoArrayList);

        
        response.sendRedirect("/dzxc/YongHu/YongHuShouYe1.jsp");

    }

    @Override
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
        try {
            doPost(request, response);
        } catch (ServletException e) {

        }
    }
}
